package com.ydc.ln.tutorial.j2se.test;

public class ThreadTest_02 implements Runnable{
	public static void main(String[] args) {
		ThreadTest_02 td = new ThreadTest_02();
		Thread t = new Thread(td);
		t.start();
	}
	int i = 0;
	public void run() {
		System.out.println(i++);
	}
	
}

class HelloThread extends Thread {
	
	public static void main(String[] args) {
		HelloThread ht1 = new HelloThread("A");
		HelloThread ht2 = new HelloThread("B");
		ht1.start();
		ht2.start();
	}
	
	private String name;
	
	public HelloThread(String name) {
		this.name = name;
	}
	
	public void run() {
		for (int i=0; i<5; i++) {
			System.out.println(name + " 运行 " + i);
			try {
				this.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
